﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyTest
{
    /// <summary>
    /// Product2 的摘要说明
    /// </summary>
    public class Product2 : IComparable
    {
        private String name;
        private String typeName;

        public string Name { get => name; set => name = value; }
        public string TypeName { get => typeName; set => typeName = value; }

        public Product2()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }

        public Product2(string name , string typeName)
        {
            this.name = name;
            this.typeName = typeName;
        }

        public override bool Equals(object obj)
        {
            var product = obj as Product2;
            return product != null &&
                   name == product.name &&
                   typeName == product.typeName;
        }

        public override int GetHashCode()
        {
            var hashCode = -1308945084;
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(name);
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(typeName);
            return hashCode;
        }

        public int CompareTo(object obj)
        {
            return name.CompareTo((obj as Product2).name);
            
        }
    }
}
